#include <stdio.h>
#include <math.h>

int maxv(int* v,int N) {
	
	int max = *v;
	for(int i=1; i<N; i++) {
		if(*(v+i)>max) {
			max = v[i];
		}
	}
	return max;
}

int translate(char*p,int N) {
	int decimalnum=0, temp;
	for(int i=0; i<N; i++) {
		temp = *p-48;
		for(int j=0; j<N-i-1; j++) {
			temp *= 2; 
		}
		decimalnum += temp;
		p = p+1;
	}
	return decimalnum;
}

int translate2(char*p,int N) {
	if(N==0){
		return 0;
	}else{
		return (*p-48)*(int)pow(2,N-1)+translate(p+1,N-1);
	}
}

int translate3(char*p,int N) {
	if(N==1){
		return *p-48;
	}else{
		return translate3(p,N-1)*2+(p[N-1]-48);
	}
}

int main()
{
	char a[12] = "helloworld!";//
	int* p = (int*)&a[0];	   //01101111 01110111 01101111 01110010
	for(int i=0; i<3; i++) {   //01101100 01100100 00100001 00000000 
		printf("%d\n",p[i]);
	}
	char q[33] = "01101100011011000110010101101000";
	char w[] = "01110010011011110111011101101111";
	char e[] = "00000000001000010110010001101100";
	printf("%d %d %d\n",translate3(q,32),translate3(w,32),translate3(e,32));
	/*short b[2] = {1,2};
	int* q = (int*)&b[0];//00000001 00000000 00000010 00000000
	printf("%d\n",*q);
	int a = 131073;
	short b = *(short*)&a;
	short c = *((short*)&a+1);
	printf("%d %d\n",b ,c);*/
	//printf("%d\n",maxv(a,3));	
	return 0;
}
